package com.qfedu.edu.exception.notify.observer.impl;

import com.qfedu.edu.exception.notify.observer.base.Observer;
import com.qfedu.edu.exception.notify.observer.base.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author xiaobobo
 * @title: SubjectImpl
 * @projectName cd-fy-2401-third-project-parent
 * @description: TODO
 * @date 2024/9/23  14:29
 */
@Component
public class SubjectImpl implements Subject {

    @Autowired
    private List<Observer> observers;

    @Override
    public void notifyMessage(String msg) {
        for (int i = 0; i < observers.size(); i++) {
            Observer observer = observers.get(i);
            observer.notifyMessage(msg);
        }
    }
}
